<?php

class Notifier {

    public static function notify($subject, $email, $template, $lang, $params = array()) {

        $tpl = new mySmarty();

        // TODO: fix it
        $tpl->register_function('wrapArtistLink', 'wrapArtistLink');
        $tpl->register_function('wrapReleaseLink', 'wrapReleaseLink');

        $tpl->register_function('wrapArtistName', 'wrapArtistName');
        $tpl->register_function('wrapReleaseName', 'wrapReleaseName');
        $tpl->register_function('wrapTagName', 'wrapTagName');
        $tpl->register_function('extract_year_from_string', 'extract_year_from_string');
        $tpl->register_function('get_album_length', 'get_album_length');
        $tpl->register_function('firstGenre', 'firstGenre');
        $tpl->register_function('filterGenre', 'filterGenre');

        foreach($params as $key => $value) {

            $tpl->assign($key, $value);
        }

        set_lang($lang);

        if(Mailer::sendMail($email, $subject, $tpl->fetch($_SERVER['DOCUMENT_ROOT'].'notice_tpl/'.$template), 'robot@musdb.net', 'notification'))
            return true;
        else
            return false;
    }

}